namespace oms.Shared;

/// <summary>
/// 通用返回结果类
/// </summary>
public class Result : Dictionary<string, object>
{
    /// <summary>
    /// 返回结果数据结构中代码字段的名字
    /// </summary>
    private const string CodeName = "code";

    /// <summary>
    /// 返回结果数据结构中信息字段的名字
    /// </summary>
    private const string MsgName = "message";

    /// <summary>
    /// 返回结果数据结构中数据字段的名字
    /// </summary>
    private const string DataName = "data";

    /// <summary>
    /// 设置返回结果代码
    /// </summary>
    /// <param name="code">结果代码</param>
    /// <returns>返回结果对象</returns>
    public Result SetCode(int code)
    {
        this[CodeName] = code;
        return this;
    }

    /// <summary>
    /// 设置返回结果信息
    /// </summary>
    /// <param name="message">结果信息</param>
    /// <returns>返回结果对象</returns>
    public Result SetMessage(string message)
    {
        this[MsgName] = message;
        return this;
    }

    /// <summary>
    /// 设置返回结果内容
    /// </summary>
    /// <param name="data">结果内容</param>
    /// <returns>返回结果对象</returns>
    public Result SetData(object data)
    {
        this[DataName] = data;
        return this;
    }
}